package com.grzx.protocol.handler.event;

import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Component;

import com.grzx.protocol.handler.Handler;
import com.grzx.protocol.handler.HandlerMapper;
import com.grzx.protocol.message.event.BaseEvent;
import com.grzx.protocol.message.util.Type;

@Component(Type.Event.REQ_MESSAGE_TYPE_EVENT)
public class EventHandler implements Handler {

	@Inject
	private HandlerMapper handlerMapper;

	@Override
	public String process(Map<String, String> map) {
		
		BaseEvent request = new BaseEvent(map);

		String event = request.getEvent();
		
		Handler handler = handlerMapper.getProtocol(event);
		
		if (handler != null) {
			return handler.process(map);
		}
		
		return "";
	}

}
